import request from "@/utils/request";

// const USER_BASE_URL = "/api/v1/users";
// const USER_BASE_URL = "/core/config";

const USER_BASE_URL = "/core/config";
export enum ConfigType {
  PROD_HEAD = "tProdheadStatus",
  PROD_CODE = "productCode",
  PAYMENT_TERMS = "paymentTerms",
  TRANSACTION_TERMS = "transactionTerms",
  MOVE_CATEGORY = "moveCategory",
  WAREHOUSE_CODE = "warehouseCode",
  PURCHASE_CATEGORY = "purchaseCategory",
  WAREHOUSE_TYPE = "warehouseType",
  TRAN_IN_REASON = "tranInReason",
  TRAN_OUT_REASON = "tranOutReason",
  Unit = "unit",
  BREACH_TERMS = "breachTerms",
  FINAL_CODE = "finalCode",
  PACKAGE_TYPE = "packageType",
  SUPP_TYPE = "suppType",
  MONITER_VIDEO = "moniterVideo",
}

const configApi = {
  //获取生产单状态配置项
  getConfigListByType(query: ConfigType) {
    return request<any, ConfigData[]>({
      url: `${USER_BASE_URL}/getConfigListByType?codeType=${query}`,
      method: "get",
    });
  },
  // 获取产品类型 原材料类型
  getTypePage(queryParams: any) {
    let query = encodeURIComponent(JSON.stringify({ ...queryParams }));
    return request<any, any>({
      url: `/core/product/category/getProductCategoryList?object=${query}`,
      method: "get",
    });
  },
  // 获取产品名称 原材料名称
  getProductList(queryParams: ProductPageQuery) {
    let query = encodeURIComponent(JSON.stringify({ ...queryParams }));
    return request<any, PageResult<ProductData[]>>({
      url: `/core/product/getProductList?object=${query}`,
      method: "get",
    });
  },
};

export default configApi;

export interface ConfigData {
  codeName: string;
  codeType: string;
  codeValue: string;
  createTime: string;
  remark: null;
  remark1: null;
  remark2: null;
  remark3: null;
  sort: null;
  updateTime: string;
}
export interface ProductPageQuery extends PageQuery {
  //类型 1=产品 2=原材料
  productType?: string;
  contractCode?: string;
  parentCode?: string;
}
export interface ProductData {
  // list: never[];
  code: string;
  productName: string;
  unit: string;
}
